package demo2;

public class TestLambda {
    //2、静态内部类
    static class Like2 implements ILike{
        @Override
        public void lambda() {
            System.out.println("like lambda..2");
        }
    }

    public static void main(String[] args) {
        //3、局部内部类
        class Like3 implements ILike{
            @Override
            public void lambda() {
                System.out.println("like lambda..3");
            }
        }

        ILike like;
        like = new Like();
        like.lambda();

        like = new Like2();
        like.lambda();

        like = new Like3();
        like.lambda();

        //4、匿名类
        like = new ILike() {
            @Override
            public void lambda() {
                System.out.println("like lambda..4");
            }
        };
        like.lambda();

        //5、lambda表达式
        like=()->{
            System.out.println("like lambda..5");
        };
        like.lambda();
    }
}


//1、实现类
class Like implements ILike {
    @Override
    public void lambda() {
        System.out.println("like lambda..1");
    }
}

interface ILike{
    void lambda();
}